package org.admanager.simplifiedsca.plugin.simplifiedsca.diagram.part;

import java.util.Collections;
import java.util.List;

import org.admanager.simplifiedsca.plugin.simplifiedsca.diagram.providers.SimplifiedSCAElementTypes;
import org.eclipse.gef.Tool;
import org.eclipse.gef.palette.PaletteContainer;
import org.eclipse.gef.palette.PaletteDrawer;
import org.eclipse.gef.palette.PaletteRoot;
import org.eclipse.gef.palette.ToolEntry;
import org.eclipse.gmf.runtime.diagram.ui.tools.UnspecifiedTypeConnectionTool;
import org.eclipse.gmf.runtime.diagram.ui.tools.UnspecifiedTypeCreationTool;

/**
 * @generated
 */
public class SimplifiedSCAPaletteFactory {

	/**
	 * @generated
	 */
	public void fillPalette(PaletteRoot paletteRoot) {
		paletteRoot.add(createSCAElement1Group());
		paletteRoot.add(createSCAConnector2Group());
	}

	/**
	 * Creates "SCA Element" palette tool group
	 * @generated
	 */
	private PaletteContainer createSCAElement1Group() {
		PaletteDrawer paletteContainer = new PaletteDrawer(
				Messages.SCAElement1Group_title);
		paletteContainer.setId("createSCAElement1Group"); //$NON-NLS-1$
		paletteContainer.add(createComponent1CreationTool());
		paletteContainer.add(createComponentReference2CreationTool());
		paletteContainer.add(createComponentService3CreationTool());
		paletteContainer.add(createComposite4CreationTool());
		paletteContainer.add(createReference5CreationTool());
		paletteContainer.add(createService6CreationTool());
		return paletteContainer;
	}

	/**
	 * Creates "SCA Connector" palette tool group
	 * @generated
	 */
	private PaletteContainer createSCAConnector2Group() {
		PaletteDrawer paletteContainer = new PaletteDrawer(
				Messages.SCAConnector2Group_title);
		paletteContainer.setId("createSCAConnector2Group"); //$NON-NLS-1$
		paletteContainer
				.add(createReferencetoComponentReference1CreationTool());
		paletteContainer.add(createServicetoComponentService2CreationTool());
		paletteContainer
				.add(createComponentReferencetoComponentService3CreationTool());
		return paletteContainer;
	}

	/**
	 * @generated
	 */
	private ToolEntry createComponent1CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.Component1CreationTool_title,
				Messages.Component1CreationTool_desc,
				Collections
						.singletonList(SimplifiedSCAElementTypes.Component_3001));
		entry.setId("createComponent1CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(SimplifiedSCAElementTypes
				.getImageDescriptor(SimplifiedSCAElementTypes.Component_3001));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createComponentReference2CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.ComponentReference2CreationTool_title,
				Messages.ComponentReference2CreationTool_desc,
				Collections
						.singletonList(SimplifiedSCAElementTypes.ComponentReference_3002));
		entry.setId("createComponentReference2CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(SimplifiedSCAElementTypes
				.getImageDescriptor(SimplifiedSCAElementTypes.ComponentReference_3002));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createComponentService3CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.ComponentService3CreationTool_title,
				Messages.ComponentService3CreationTool_desc,
				Collections
						.singletonList(SimplifiedSCAElementTypes.ComponentService_3003));
		entry.setId("createComponentService3CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(SimplifiedSCAElementTypes
				.getImageDescriptor(SimplifiedSCAElementTypes.ComponentService_3003));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createComposite4CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.Composite4CreationTool_title,
				Messages.Composite4CreationTool_desc,
				Collections
						.singletonList(SimplifiedSCAElementTypes.Composite_2001));
		entry.setId("createComposite4CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(SimplifiedSCAElementTypes
				.getImageDescriptor(SimplifiedSCAElementTypes.Composite_2001));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createReference5CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.Reference5CreationTool_title,
				Messages.Reference5CreationTool_desc,
				Collections
						.singletonList(SimplifiedSCAElementTypes.Reference_3004));
		entry.setId("createReference5CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(SimplifiedSCAElementTypes
				.getImageDescriptor(SimplifiedSCAElementTypes.Reference_3004));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createService6CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.Service6CreationTool_title,
				Messages.Service6CreationTool_desc,
				Collections
						.singletonList(SimplifiedSCAElementTypes.Service_3005));
		entry.setId("createService6CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(SimplifiedSCAElementTypes
				.getImageDescriptor(SimplifiedSCAElementTypes.Service_3005));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createReferencetoComponentReference1CreationTool() {
		LinkToolEntry entry = new LinkToolEntry(
				Messages.ReferencetoComponentReference1CreationTool_title,
				Messages.ReferencetoComponentReference1CreationTool_desc,
				Collections
						.singletonList(SimplifiedSCAElementTypes.ReferencePromote_4001));
		entry.setId("createReferencetoComponentReference1CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(SimplifiedSCADiagramEditorPlugin
				.findImageDescriptor("/org.admanager.soageneralpattern.plugin/icons/full/obj16/Relationship.gif")); //$NON-NLS-1$
		entry.setLargeIcon(SimplifiedSCADiagramEditorPlugin
				.findImageDescriptor("/org.admanager.soageneralpattern.plugin/icons/full/obj16/Relationship.gif")); //$NON-NLS-1$
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createServicetoComponentService2CreationTool() {
		LinkToolEntry entry = new LinkToolEntry(
				Messages.ServicetoComponentService2CreationTool_title,
				Messages.ServicetoComponentService2CreationTool_desc,
				Collections
						.singletonList(SimplifiedSCAElementTypes.ServicePromote_4002));
		entry.setId("createServicetoComponentService2CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(SimplifiedSCADiagramEditorPlugin
				.findImageDescriptor("/org.admanager.soageneralpattern.plugin/icons/full/obj16/Relationship.gif")); //$NON-NLS-1$
		entry.setLargeIcon(SimplifiedSCADiagramEditorPlugin
				.findImageDescriptor("/org.admanager.soageneralpattern.plugin/icons/full/obj16/Relationship.gif")); //$NON-NLS-1$
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createComponentReferencetoComponentService3CreationTool() {
		LinkToolEntry entry = new LinkToolEntry(
				Messages.ComponentReferencetoComponentService3CreationTool_title,
				Messages.ComponentReferencetoComponentService3CreationTool_desc,
				Collections
						.singletonList(SimplifiedSCAElementTypes.ComponentReferenceTarget_4003));
		entry.setId("createComponentReferencetoComponentService3CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(SimplifiedSCADiagramEditorPlugin
				.findImageDescriptor("/org.admanager.soageneralpattern.plugin/icons/full/obj16/Relationship.gif")); //$NON-NLS-1$
		entry.setLargeIcon(SimplifiedSCADiagramEditorPlugin
				.findImageDescriptor("/org.admanager.soageneralpattern.plugin/icons/full/obj16/Relationship.gif")); //$NON-NLS-1$
		return entry;
	}

	/**
	 * @generated
	 */
	private static class NodeToolEntry extends ToolEntry {

		/**
		 * @generated
		 */
		private final List/*[org.eclipse.gmf.runtime.emf.type.core.IElementType]*/elementTypes;

		/**
		 * @generated
		 */
		private NodeToolEntry(
				String title,
				String description,
				List/*[org.eclipse.gmf.runtime.emf.type.core.IElementType]*/elementTypes) {
			super(title, description, null, null);
			this.elementTypes = elementTypes;
		}

		/**
		 * @generated
		 */
		public Tool createTool() {
			Tool tool = new UnspecifiedTypeCreationTool(elementTypes);
			tool.setProperties(getToolProperties());
			return tool;
		}
	}

	/**
	 * @generated
	 */
	private static class LinkToolEntry extends ToolEntry {

		/**
		 * @generated
		 */
		private final List/*[org.eclipse.gmf.runtime.emf.type.core.IElementType]*/relationshipTypes;

		/**
		 * @generated
		 */
		private LinkToolEntry(
				String title,
				String description,
				List/*[org.eclipse.gmf.runtime.emf.type.core.IElementType]*/relationshipTypes) {
			super(title, description, null, null);
			this.relationshipTypes = relationshipTypes;
		}

		/**
		 * @generated
		 */
		public Tool createTool() {
			Tool tool = new UnspecifiedTypeConnectionTool(relationshipTypes);
			tool.setProperties(getToolProperties());
			return tool;
		}
	}
}
